﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/include/header.jsp"%>
<style type="text/css">
.date_txt,.input_txt{
	width: 190px;
}
.selec{
		width: 195.5px;
}
</style>
</head>
<body style="background-color: white;">
      <div class="dialog_main" style="padding: 10px;">
		<div class="b_box ch_panel" style="padding: 10px;text-align: center;">
			<form id="dicObjForm">
				<input type="hidden" id="CSRFToken" name="CSRFToken" value="${csrfToken}" />
				<input type="hidden" name="uuid" value="${dicObj.uuid}" />
				<table class="c_table m_t10">
						<tr>
							<td class="t_r">字典组别：</td>
							<td class="t_l">
								<select id="dicGroupType" name="dicGroupType" class="input_txt selec" data-validaterole="dicGroupType">
									<option value="">--请选择--</option>
									<c:forEach items="${dicGroupTypeMap }" var="obj">
										<option <c:if test="${dicObj.dicGroupType eq obj.key }">selected="selected"</c:if> value="${obj.key }">${obj.value }</option>
									</c:forEach>
								</select>
							</td>
						</tr>					
						<tr>
							<td class="t_r">字典名称：</td>
							<td class="t_l"><input type="text" class="input_txt" id="dicName" name="dicName" data-validaterole="dicName" value="${dicObj.dicName}" /></td>
						</tr>					
						<tr>
							<td class="t_r">字典代码：</td>
							<td class="t_l"><input type="text" class="input_txt" id="dicCode" name="dicCode" data-validaterole="dicCode" value="${dicObj.dicCode}" /></td>
						</tr>					
				</table>

			</form>
		</div>
		<div class="action_box t_c m_t15">
			<input type="button" class="a_btn" id="editBtn" value="保存" />
		</div>
	</div>

	<script type="text/javascript">
	// 验证
	seajs.use(["component/validate", "component/tip"], function(validate, tip) {
		var ntip = function () {
			// 定义一个提示对象
			var t = new tip({
				content : 'hello tip', hasArrow : true, arrowOption : {
					dir : "left", position : {
						top : 8
					}
				}, con : "body", hasCloseBtn : false, position : {
					my : "center", at : "center", of : "#tipcon"
				}, css : {
					width : "20"
				}
			});
			return t;
		};

		var d = new validate({
			con: "#dicObjForm",
			// 验证容器
			ntip: ntip,
			onSubmit: "#editBtn" // 提交按钮
		});

		// 设置拼装规则: 这里加上各个验证规则
		d.setValidateRule({ reportName: ["isBlank", "checkLen"] });
		d.setValidateRule({ reportCode: ["isBlank", "checkLen"] });
		d.setValidateRule({ dicName: ["isBlank", "checkLen"] });
		d.setValidateRule({ dicCode: ["isBlank", "checkLen"] });
		// 注册保存按钮事件
		d.bind("onsubmit", function() {
			
			var serializedForm = $("#dicObjForm").serialize();
			$.post("${ctx}/dicObj/edit", serializedForm, function(result){
				if ("succ" == result) {
					alert("操作成功");
					parent.replaceByUrl('${ctx}/dicObj/list');
					parent.layerClose(window.name);
				} else {
					alert(result);
				}
			});
				
		});
	});
	
	</script>
</body>
</html>